﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace UcAsp.Net.Extract.Plug.Rayli
{
    public partial class UcAspSettingControl : UserControl
    {
        public UcAspSettingControl()
        {
            InitializeComponent();
        }

        private void btnNext_Click(object sender, EventArgs e)
        {
            tabControl1.SelectTab(tabPage2);

        }

        private void UcAspSettingControl_Load(object sender, EventArgs e)
        {
            List<Model.Config> list = BLL.Config.GetListConfig;
            lbConfig.DataSource = list;
            lbConfig.DisplayMember = "DefinedTitle";
            lbConfig.ValueMember = "DefinedName";
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            Model.FilesConfig file = new Model.FilesConfig();
            file.FileName = txtFileName.Text;
            file.Name = txtName.Text;
            file.ContentReg = txtContentReg.Text;
            file.ImageReg = txtImageReg.Text;
            file.PageReg = txtPageReg.Text;
            file.Url = txtURL.Text;
            file.URLReg = txtUrlReg.Text;
            file.TitleReg = txtTitleReg.Text;
            file.RootPath = txtrootPath.Text;
            file.PageUrl = txtPageUrl.Text;
            file.PageNumber = int.Parse(txtPageNumber.Text);
            file.ClearReg = txtClearReg.Text;
            file.CategorieID = int.Parse(txtCategorieID.Text);
            file.PicContentReg = txtPicContentReg.Text;
            file.PicImageReg = txtPicImageReg.Text;
            file.PicTitleReg = txtPicTitleReg.Text;
            file.PicPage = txtPicPageReg.Text;
            BLL.FilesConfig.SaveFilesConfig(file, file.FileName);
        }

        private void btnNextpage_Click(object sender, EventArgs e)
        {
            tabControl1.SelectTab(tabPage3);
        }

        private void lbConfig_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            ListBox list = (ListBox)sender;
            Model.FilesConfig config = BLL.FilesConfig.GetFilesConfig(list.SelectedValue.ToString());
            txtFileName.Text = config.FileName;
            txtName.Text = config.Name;
            txtURL.Text = config.Url;
            txtUrlReg.Text = config.URLReg;
            txtContentReg.Text = config.ContentReg;
            txtImageReg.Text = config.ImageReg;
            txtTitleReg.Text = config.TitleReg;
            txtPageReg.Text = config.PageReg;
            txtrootPath.Text = config.RootPath;
            txtPageUrl.Text = config.PageUrl;
            txtPageNumber.Text = config.PageNumber.ToString();
            txtClearReg.Text = config.ClearReg;
            txtPicImageReg.Text = config.PicImageReg;
            txtPicTitleReg.Text = config.PicTitleReg;
            txtPicContentReg.Text = config.PicContentReg;
            txtCategorieID.Text = config.CategorieID.ToString();
            txtPicPageReg.Text = config.PicPage;
        }
    }
}
